<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script>
var flag=false;
$(document).ready(function(){
	$("#content_submit").click(function(){
		$(":input[name=genre]").each(function(index,data){
			if(data.checked){
				flag=true;				
				return;
			}			
		});	
		if($(":input[name=title]").val()==""){
			alert("제목을 입력하세요!");
			return;
		}else if($("#directorSelect").val()==0){
			alert("감독을 선택하세요!");
			return;
		}else if(flag==false){
			alert("장르를 선택하세요!");
			return;
		}else if($(":input[name=story]").val()==""){
			alert("스토리를 입력하세요!");
			return;
		}else if($(":input[name=posterFile]").val()==""){
			alert("포스터를 등록하세요!");
			return;
		}else if($(":input[name=trailerPath]").val()==""){
			alert("트레일러 영상을 등록하세요!");
			return;
		}
		
		$("#movieWrite").submit();
	});
});
</script>
<h3>영화 - 등록</h3>
<hr align="left" width="150">
<center>
<form id="movieWrite" action="${initParam.root }admin/movieWrite.do" enctype="multipart/form-data" method="post">
<table class="movieWrite">
	<caption>영화 등록하기</caption>
	<tbody>
		<tr>
			<td>영화제목</td><td align="left"><input type="text" name="title" size="20"></td>
		</tr>
		<tr>
			<td>감독이름</td>
			<td align="left" colspan="3">
				<select class="select" name="directorNo" id="directorSelect">
					<option value="0">--감독--</option>
					<c:forEach items="${requestScope.directorList }" var="data">
						<option value="${data.directorNo }">${data.name }</option>
					</c:forEach>	
				</select>
			</td>
		</tr>
		<tr>
			<td>장르</td>
			<td align="center">
				<input type="radio" name="genre" value="액션/스릴러">액션/스릴러
				<input type="radio" name="genre" value="SF">SF
				<input type="radio" name="genre" value="드라마">드라마
				<input type="radio" name="genre" value="코미디">코미디
				<input type="radio" name="genre" value="애니메이션">애니메이션
			</td>
		</tr>
		<tr>
			<td>스토리</td><td align="left"><pre><textarea cols="60" rows="10" name="story" id="content" style="resize:none;"></textarea></pre></td>
		</tr>
		<tr>
			<td>포스터</td><td align="left"><input type="file" name="posterFile"></td>
		</tr>
		<tr>
			<td>예고편 경로</td><td align="left"><input type="text" name="trailerPath"></td>
		</tr>
		<tr>
			<td>수상정보</td><td align="left"><input type="text" name="info" size="20"></td>
		</tr>
		<tr>
			<td colspan="4" align="center">
				<input type="button" class="button" id="content_submit" value="영화등록">
				<button class="button" id="cancel">작성취소</button>
			</td>
		</tr>
	</tbody>
</table>	
</form>
</center>